#include"common.h"

int main()
{
  umask(0);
  int mk =  mkfifo(PATH_NAME,0666);
  if(mk < 0)
  {
    perror("mkfifo");
    return 1;
  }
  //读取操作
  int fd = open("./myfifo",O_RDONLY);
  if(fd < 0)
  {
    perror("open");
    return 2;
  }
  while(1)
  {
    char buffer[64];
    int s = read(fd,buffer,sizeof(buffer));
    if(s < 0)
    {
      perror("read");
      return 3;
    }
    else if(s == 0)
    {
      printf("client quit........\n");
      return 4;
    }
    else{
      buffer[s-1] = 0;
      printf("client# %s\n",buffer);
    }
  }
  close(fd);
  return 0;
}
